package net.superdvach.core;

import static org.junit.Assert.*;

import org.junit.*;

// Not a unit test, actually, but no one cares...
public class ConfigTest {

	@Test
	public void testAccessors() {
		Config config = new Config("config");
		config.setProperty("foo", "bar");
		assertEquals("bar", config.getProperty("foo"));
		assertEquals("qux", config.getProperty("banana", "qux"));
	}

	@Test
	public void testPersistance() {
		Config config = new Config("config");
		config.delete();
		boolean res = config.load();
		assertEquals(false, res);
		config.setProperty("foo", "42");
		res = config.save();
		assertEquals(true, res);

		Config another = new Config("config");
		res = another.load();
		assertEquals(true, res);
		assertEquals("42", another.getProperty("foo"));
	}
	
	@AfterClass
	public static void afterClass() {
		Config config = new Config("config");
		config.delete();
	}

}
